<?php
    $menu_1 = ' class="active"';
    $menu_2 = '';
    $menu_3 = '';
    $menu_4 = '';
    $menu_5 = '';
    $menu_6 = '';
    $menu_7 = '';
    $menu_8 = '';
    include('header.php');
    
    $sql = "SELECT * FROM news WHERE news_active=1 ORDER BY news_date DESC LIMIT 0,1";
    $result_news = $db->Execute($sql);
    if(img_exists(APPPATH.'/images/news',$result_news->fields['news_img'])){
	$img_news = '<img src="'.SITEURL.'/images/news/'.$result_news->fields['news_img'].'" />';
    }else{
	$img_news = '<img src="'.SITEURL.'/images/no_img.jpg" />';
    }
    
    $sql = "SELECT * FROM relate_article WHERE ra_active=1 ORDER BY ra_date DESC LIMIT 0,1";
    $result_relate = $db->Execute($sql);
    if(img_exists(APPPATH.'/images/relate-article/'.$result_relate->fields['ra_id'],$result_relate->fields['ra_img'])){
	$img_relate = '<img src="'.SITEURL.'/images/relate-article/'.$result_relate->fields['ra_id'].'/'.$result_relate->fields['ra_img'].'" />';
    }else{
	$img_relate = '<img src="'.SITEURL.'/images/no_img.jpg" />';
    }
    
    $sql = "SELECT * FROM rss_news WHERE rn_active=1 ORDER BY rn_date DESC LIMIT 0,1";
    $result_rss = $db->Execute($sql);
    if(img_exists(APPPATH.'/images/rss-news/'.$result_rss->fields['rn_id'],$result_rss->fields['rn_img'])){
	$img_rss = '<img src="'.SITEURL.'/images/rss-news/'.$result_rss->fields['rn_id'].'/'.$result_rss->fields['rn_img'].'" />';
    }else{
	$img_rss = '<img src="'.SITEURL.'/images/no_img.jpg" />';
    }
    
    $sql = "SELECT * FROM home_slide ORDER BY hs_id DESC";
    $result = $db->Execute($sql);
    $slide_list = '';
    while (!$result->EOF)
    {
        if(img_exists(APPPATH.'/images/home-slide',$result->fields['hs_path'])){
            $slide_list .= '<img src="'.SITEURL.'/images/home-slide/'.$result->fields['hs_path'].'" />';
        }else{
        }
        $result->MoveNext();
    }
    $result->Close();
    
    $sql = "SELECT * FROM text_data WHERE td_id=16";
    $result = $db->Execute($sql);
    while (!$result->EOF)
    {
	$slide_bottom_msg = $result->fields['td_th'];
        $result->MoveNext();
    }
    $result->Close();
?>
	    <div id="main_content">
		
		<!--<div id="home_slide" class="slider-wrapper theme-default">-->
		<!--    <div class="ribbon"></div>-->
		<div id="home_slide_x">
		    <div id="home_slide_" class="nivoSlider">
			<?php echo $slide_list; ?>
		    </div>
		    <div id="index_slide_bg"><img src="<?php echo SITEURL; ?>/images/index_slide_bg.png" /></div>
		</div>
		<!--</div>-->
		
		<div id="home_msg">
		    <span><?php echo $slide_bottom_msg; ?></span>
		</div>
		
		<div id="" class="home_box">
		    <h3><span>News & Event</span></h3>
		    <?php echo $img_news; ?>
		    <p class="home_box_msg">
			<?php echo substr_utf8(stripslashes($result_news->fields['news_msg_1']) , 0 , 83); ?>
		    </p>
		    <p class="home_box_readmore"><a href="news.php" title="" class="text_green">+ readmore +</a></p>
		</div>
		<div id="" class="home_box">
		    <h3><span>Related Articles</span></h3>
		    <?php echo $img_relate; ?>
		    <p class="home_box_msg">
			<?php echo substr_utf8(stripslashes($result_relate->fields['ra_msg']) , 0 , 83); ?>
		    </p>
		    <p class="home_box_readmore"><a href="related-articles.php" title="" class="text_green">+ readmore +</a></p>
		</div>
		<div id="" class="home_box home_box_last">
		    <h3><span>RSS News</span></h3>
		    <?php echo $img_rss; ?>
		    <p class="home_box_msg">
			<?php echo substr_utf8(stripslashes($result_rss->fields['rn_desc']) , 0 , 83); ?>
		    </p>
		    <p class="home_box_readmore"><a href="rss-news.php" title="" class="text_green">+ readmore +</a></p>
		</div>
		<div class="clear">&nbsp;</div>
		
		
	    </div>
<?php
    include('footer.php')
?>
<!--<link rel="stylesheet" href="<?php echo SITEURL; ?>/css/themes/default/default.css" type="text/css" media="screen" />-->
<!--<link type="text/css" href="<?php echo SITEURL; ?>/css/nivo-slider.css" rel="stylesheet" />-->
<script type="text/javascript" src="<?php echo SITEURL; ?>/js/jquery.cycle.all.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('#home_slide_').cycle({
		speed:5000,
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
    
//    $('#home_slide_').nivoSlider({
//	animSpeed:1500, // Slide transition speed
//        pauseTime:5000, // How long each slide will show
//    });
});
</script>